{{ $.Scratch.Set "hasReplies" 0 }}
{{ range $index, $comments := (index $.SiteDataComments_parent $.entryId_parent ) }}

{{ if ne $.parentId nil }}
{{ end }}

{{ if eq .reply_to $.parentId }}
    {{ $.Scratch.Add "hasReplies" 1 }}
    <div class="post-comment-reply">
      <div class="post-comment-header">
          <p class="post-comment-info" id="{{ ._id }}"><strong>{{ .name }}</strong> on {{ dateFormat "Monday, Jan 2, 2006" .date }}<br><i><small>In reply to {{ $.parentName }}</i></small><br></p>
      </div>
      {{ .body | markdownify }}
      <p>{{ $.Scratch.Get "hasReplies" }}</p>
    </div>
{{ end }}
<!-- newly introduced code, doesnt do anything yet -->
{{ if gt ($.Scratch.Get "hasReplies") 0 }}
      <a id="{{ ._id }}" class="post-comment-info" href="#comment-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">Reply to Thread</a>
{{end }}
{{ end }}

<!-- started looking here 
    https://github.com/dancwilliams/networkhobo/issues/373
and here
    https://github.com/halogenica/beautifulhugo/pull/222
but I never finished -->


